package com.ss.android.push.sswo;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
import com.bytedance.common.utility.Logger;
import java.lang.ref.WeakReference;

public class SswoActivity extends Activity {
    private static WeakReference a;

    public SswoActivity() {

    }

    public boolean dispatchTouchEvent(MotionEvent arg2) {
        if(!this.isFinishing()) {
            this.finish();
        }

        return super.dispatchTouchEvent(arg2);
    }

    public void finish() {
        super.finish();
        this.overridePendingTransition(0, 0);
    }

    public static void finishOffActivity(Context arg2) {
        try {
            if(SswoActivity.a == null) {
                return;
            }

            Object v0_1 = SswoActivity.a.get();
            if(v0_1 == null) {
                return;
            }

            if(((SswoActivity)v0_1).isFinishing()) {
                return;
            }

            ((SswoActivity)v0_1).finish();
        }
        catch(Throwable v0) {
            v0.printStackTrace();
        }
    }

    public static boolean isFinish() {
        try {
            if(SswoActivity.a == null) {
                return true;
            }

            Object v0_1 = SswoActivity.a.get();
            if(v0_1 == null) {
                return true;
            }

            boolean v0_2 = ((SswoActivity)v0_1).isFinishing();
            return v0_2;
        }
        catch(Throwable v0) {
            v0.printStackTrace();
        }

        return true;
    }

    protected void onCreate(Bundle arg4) {
        super.onCreate(arg4);
        if(Logger.debug()) {
            Logger.d("SswoActivity", "onCreate");
        }

        try {
            Window v0_1 = this.getWindow();
            v0_1.setGravity(51);
            WindowManager.LayoutParams v1 = v0_1.getAttributes();
            v1.x = 35;
            v1.y = 0;
            v1.height = 1;
            v1.width = 1;
            v0_1.setAttributes(v1);
        }
        catch(Throwable v0) {
            Logger.e("SswoActivity", v0.getMessage(), v0);
        }

        SswoActivity.a = new WeakReference(this);
    }

    protected void onDestroy() {
        super.onDestroy();
        if(Logger.debug()) {
            Logger.d("SswoActivity", "onDestroy");
        }

        if(SswoActivity.a != null && SswoActivity.a.get() == this) {
            SswoActivity.a.clear();
            SswoActivity.a = null;
        }
    }

    protected void onStart() {
        super.onStart();
        if(!SswoManager.inst(((Context)this)).isScreenOff() && !this.isFinishing()) {
            this.finish();
        }
    }

    public boolean onTouchEvent(MotionEvent arg2) {
        if(!this.isFinishing()) {
            this.finish();
        }

        return super.onTouchEvent(arg2);
    }

    public static void startOffActivity(Context arg2) {
        if(arg2 != null) {
            try {
                Intent v0_1 = new Intent(arg2, SswoActivity.class);
                v0_1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                arg2.startActivity(v0_1);
            }
            catch(Throwable v0) {
                v0.printStackTrace();
            }
        }
    }
}

